<?php
/**
 * 
 * Enter description here ...
 * 
 */
use Fox\Dao\SqlFragment;
use Hive\Expense\Type;
use Fox\Generator;

$xview = Xview::instance();
// Load all expenses type
global $types;
$finder = new Type();
$types = $finder->find(new SqlFragment("language = ?",array($xview->language())),null,null,null,true);

$grid = new Fox\Grid('gExpense');
$grid->fieldcat(array('expenseid',
						'expense_date','expense_reference',
						array('expense_type','type'),
						'expense_file',
						array('expense_amount','amount')
						));
						
$grid->setCoche(true);
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->setGenerators(array(
	'coche' => Generator::noData(),
	'type'  => Generator::useFunction(function ($object){
		global $types;
		if(isset($types[$object->type]))
		{
			return $types[$object->type]->label();
		}
	}),
	'expense_file' => Generator::useFunction(function ($object){
		
	}),
	'expense_reference' => Generator::useFunction(function ($object){
	//	return $object->reference()->label();
	}) 
));							
			
return $grid;